package com.zztpc.easybuy.servlet;

import com.zztpc.easybuy.dao.UserDao;
import com.zztpc.easybuy.vo.User;


import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;

public class ZhucheServlet extends javax.servlet.http.HttpServlet {
    protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {
        PrintWriter ap= response.getWriter();
        //ap.print("appppppppp");
        String username= request.getParameter("userName");
        String pwd= request.getParameter("password");
        ap.print(username+"hello");

        //调用组件
        UserDao userDao=new UserDao();
        User user=new User();
        user.setEu_user_id("006");
        user.setEu_user_name(username);
        user.setEu_password(pwd);
        boolean b=false;
        try {
            b=userDao.insert(user);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        if(b){
            System.out.println("succ");
        }else{
            System.out.println("error");
        }
    }
}
